package com.cookie.libgdx.airforcecolonel;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.cookie.libgdx.airforcecolonel.sprite.Plane;

public class TestPlane implements ApplicationListener {
	
	private AssetsUtil asset;
	private SpriteBatch spriteBatch;
	private int i=0;
	
	private Plane plane;
	
	@Override
	public void create() {
		asset = new AssetsUtil();
		this.spriteBatch  = new SpriteBatch();
		this.plane = new Plane(300, 300, 10, 10, 10, 10, 10, 10, 10);
		this.plane.accel.x = 0;
		this.plane.accel.y = -100;
		this.plane.velocity.x =30;
		this.plane.velocity.y=20;
	}

	@Override
	public void resume() {
		
	}

	@Override
	public void render() {
		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
		float deltaTime = 0.01f;
		if(Gdx.graphics.getDeltaTime()>0.01){
			deltaTime = 0.01f;
		}else{
			deltaTime = 0.01f;
		}
		this.plane.update(Gdx.graphics.getDeltaTime());
		this.spriteBatch.begin();
		this.spriteBatch.draw(asset.background, 0, 0);
		this.spriteBatch.draw(asset.summerFarBackground, 0, 100);
		this.spriteBatch.draw(asset.summerNearBackground, 0, 0);
		this.spriteBatch.draw(asset.redPlane.get(i%1), this.plane.positon.x, this.plane.positon.y);
		System.out.println(plane);
		this.spriteBatch.draw(asset.blackPlane.get(i%25), 444, 444);
		this.spriteBatch.draw(asset.greenPlane.get(i%25), 440, 488);
		this.spriteBatch.draw(asset.bluePlane.get(i%25), 488, 488);
		this.spriteBatch.end();
		this.i++;
	}

	@Override
	public void resize(int width, int height) {

	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub

	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub

	}

}
